package com.example.demo.service.impl;

import com.example.demo.entity.Person;
import com.example.demo.mapper.PersonMapper;
import com.example.demo.service.LoginService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class LoginServiceImpl implements LoginService {

    @Autowired
    PersonMapper personMapper;

    /**
     *
     * @param user_id
     * @param user_name
     * @return
     */
    @Override
    public Person loginCheck(int user_id, String user_name) {
        return personMapper.findPersonById(user_id);
    }


    /**
     * 按照等级查找用户
     * @param user_lev
     * @return
     */
    @Override
    public List<Person> findall(int user_lev) {
        return personMapper.findPersonAll(user_lev);
    }

    @Override
    public Person selectPersonById(Integer id) {
        return personMapper.findPersonById(id);
    }

    @Override
    public Person selectPersonByName(String name) {
        return personMapper.findPersonByName(name);
    }

    @Override
    public Boolean addPerson(Person person) {
        int result=personMapper.addPerson(person);
        return result>0;
    }


}
